$(function () {
    // ****************************************编辑用户
    let arr = location.href.split('=')
    let id = arr[1]

    let form;
    let layer;
    layui.use('form', function () {
        form = layui.form;
        layer = layui.layer;

        // 表单回填
        $.ajax({
            url: `/admin/users/${id}`,
            success: function (res) {
                form.val('editForm', res.data)
            }
        })


        $('form').on('submit', function (e) {
            e.preventDefault()
            let data = $(this).serialize()
            $.ajax({
                url: `/admin/users`,
                type: `PUT`,
                data: data,
                success: function (res) {
                    layer.msg(res.message)
                    location.href = '/user/user.html'
                }

            })
        })
    });































})